﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 剧情设计器2._0
{
    [Serializable]
    public class Action
    {
        //动作的发出者
        public string emitter = "";
        //动作的接收者
        public string receiver = "";
        //动作描述
        public string description = "";
        //动作类型
        public string type = "";
        //动作发生后人物的关系变化
        public List<Relationship> relationships = new List<Relationship>();

        public override int GetHashCode()
        {
            int code = emitter.GetHashCode();
            code += receiver.GetHashCode();
            code += description.GetHashCode();
            code += type.GetHashCode();
            foreach (Relationship r in relationships)
                code += r.GetHashCode();
            return code;
        }

        public void draw(Graphics g, int x, int y)
        {
            Pen pen = new Pen(Color.Black);
            const int w = 112;
            const int h = 48;
            const int textHeight = 10;
            const int rowHeifht = 16;
            g.DrawRectangle(pen, x, y, w, h);
            g.DrawLine(pen, x, y + rowHeifht, x + w, y + rowHeifht);
            g.DrawLine(pen, x, y + rowHeifht * 2, x + w, y + rowHeifht * 2);
            pen.Color = Color.Purple;
            g.DrawString(string.Format("发起者:{0}", emitter), new Font("微软雅黑", textHeight), pen.Brush, new PointF(x + 2, y));
            g.DrawString(string.Format("{0}", type), new Font("微软雅黑", textHeight), pen.Brush, new PointF(x + 2, y + rowHeifht));
            g.DrawString(string.Format("接收者:{0}", receiver), new Font("微软雅黑", textHeight), pen.Brush, new PointF(x + 2, y + rowHeifht * 2));
        }
    }
}
